package main

import (
	"fmt"
)
func main(){
	s := make([]int, 3, 3) //[0 0 0]
	modifyA(s)
	fmt.Println(s) //被修改了 [0 1 0]

	modifyB(s)
	fmt.Println(s) //没有被修改 [0 1 0]

	modifyB(s[0:2])
	fmt.Println(s) //被修改了 [0 1 2]

	modifyC(s[0:2:2])
	fmt.Println(s) //没有被修改 [0 1 2]

	modifyD(s[1:])
	fmt.Println(s) //被修改了 [0 3 2]

	x := s[1:]
	x[0] = 6
	fmt.Println(x) //[6 2]
	fmt.Println(s) //被修改了 [0 6 2]
}

func modifyA(x []int){
	x[1] = 1
}
func modifyB(x []int){
	x = append(x, 2)
}
func modifyC(x []int){
	x = append(x, 4)
}
func modifyD(x []int){
	x[0] = 3
}


